<!DOCTYPE html>
<html>
<head>
	<title></title>
	<base href="http://localhost/">
	<link rel="stylesheet" type="text/css" href="layui/css/layui.css">
	<script type="text/javascript" src="layui/layui.js"></script>
</head>
<body style="padding: 10px">
	<form method="post" action="<?=site_url('/Main/user_save')?>" name="userform">
		<div class="layui-form">
			<div class="layui-form-item">
				<label class="layui-form-label">用户名</label>
				<!-- 创建一个隐藏的input 存放id -->
				<input type="hidden"  value="<?= $data['id']?>" name="editid">
				<div class="layui-input-inline">
					<input type="text" class="layui-input" name="editname" value="<?= $data['username']?>">
				</div>
			</div>

			<div class="layui-form-item">
			<label class="layui-form-label">密&nbsp;&nbsp;&nbsp;&nbsp;码</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input" name="editpassword" value="<?= $data['userpassword']?>">
			</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">角&nbsp;&nbsp;&nbsp;&nbsp;色</label>
				<div class="layui-input-inline">
					<select class="" name="editrorle">
						<?php
						switch($data["userorle"]){
								case 1:echo "<option value='1'  >学生</option><option value='2' >老师</option><option value='3' >游客</option>";; break;
								case 2:echo "<option value='1' >学生</option><option value='2' selected = 'selected' >老师</option><option value='3' >游客</option>"; break;
								case 3:echo "<option value='1'>学生</option><option value='2'>老师</option><option value='3' selected = 'selected' >游客</option>"; break;
								default:
  								echo "<option value='1'>学生</option><option value='2'>老师</option><option value='3'>游客</option>";
							}
						?>

					</select>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">状&nbsp;&nbsp;&nbsp;&nbsp;态</label>
				<div class="layui-input-inline">
					<?php
						if($data['userstate'] ==1){
							echo"<input type='checkbox' lay-skin='primary' checked='checked'  name='editstate'  title='禁用''>";
						}else{
							echo"<input type='checkbox' vaule='1' lay-skin='primary'  name='editstate' title='禁用''>";
						}
					?>
					<!-- <input type="checkbox" lay-skin="primary" checked="checked" name="editstate" title="禁用"> -->
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" onclick="return check(userform)">保存</button>
					<!-- <button class="layui-btn" onclick="cheremove()">取消</button> -->
				</div>
			</div>

		</div>
	</form>

	<script type="text/javascript">
		layui.use(['layer','form'],function(){
			form = layui.form;
			layer = layui.layer;
			$ = layui.jquery;
		});
		// function cheremove(){
		// 	var mylay = parent.layer.getFrameIndex(window.name);
		// 	parent.layer.close(mylay);
		// };
		function check(form){
			if(form.username.value == ""){
				alert("用户名不能为空");
				form.username.focus();
				return false;
			}
			if(form.userpassword.value == ""){
				alert("密码不能为空");
				form.userpassword.focus();
				return false;
			}
			form.submit;
			//提交完成关闭模态框
			var mylay = parent.layer.getFrameIndex(window.name);
			parent.layer.close(mylay);
		}

	</script>
</body>
</html>